<include file="Public/head"/>
<script src="{:get_style_cdnurl()}paimai/yunying/js/city.js" type="text/javascript"></script>
</head>
<include file="Public/common_header"/>
<div class="mian">
    <include file="Public/sidebar" menu='zhgl.grzh'/>
    <div class="mianR">
        <h3 class="yonghu">设置牛人</h3>
        <div class="cattle clearfix">
            <span class="good-brand">擅长品牌</span><script src="{:get_style_cdnurl()}paimai/cheshan/js/model_select.js" type="text/javascript"></script>
            <input type="hidden" value="" name="good_brand" id="good_brand" />
        </div>
        <div class="brand-choice clearfix">
            <ul></ul>
        </div>
        <div class="cattle-title">
            <span>牛人介绍</span>
            <textarea name="expert_intro" id="expert_intro"></textarea>
        </div>
        <div class="yongBtn">
            <input type="button" data-id="2" value="确定" class="queding">
            <input type="button" class="quxiao" onclick="history.go(-1);" value="取消">
        </div>
    </div>
    <div class="clear"></div>
</div>
<div class="loading"></div>
<style type="text/css">
    .cattle{padding:20px 20px 15px 20px;}
    .cattle .chexing{padding-left:10px;}
    .cattle span.good-brand{float: left;font-size:14px;display: block;height: 24px; line-height: 24px;}
    .cattle-title{ text-align: left; display: block;}
    .cattle-title{padding:20px;}
    .cattle-title span{padding-right:10px;color:#303030;float: left; display: block;font-size:14px;}
    .cattle-title textarea{padding:5px; resize:none;font-size:14px;font-family:"微软雅黑";width:600px;border:solid 1px #dadada;height: 150px;}
    .brand-choice{padding-left:86px;text-align: left; display: block;}
    .brand-choice ul li{margin-right:15px;color:#303030;position:relative;border:solid 1px #afafaf;border-radius:3px;padding:5px 10px; display: block;float: left;}
    .brand-choice ul li span{cursor:pointer;width:12px;height:12px; line-height:11px; text-align: center;border-radius:50%; background:#20ab4f;position:absolute;top:-5px;right:-5px;font-weight:bold;color:#fff;}
</style>
<script>
    ModelSelect.not_allow_model  = true; //不使用车型
    ModelSelect.not_allow_serires = true; //不使用车系
</script>
</div>
<script>
    $(function(){
        $(".queding").click(function(){
            var good_brand = $('#good_brand').val();
            var expert_intro = $('#expert_intro').val();
            if(good_brand == ''){
                shibai_alert('擅长品牌不能为空');
                return false;
            }
            if(expert_intro == ''){
                shibai_alert('牛人介绍不能为空');
                return false;
            }
            $(".yunBei").css("display","block").unbind('click')
            $(".loading").fadeIn();
            var post_data = {
                'uid':"{$user_id}",
                'brand':good_brand,
                'intro':expert_intro
            }
            $.post("{:U('ClcwUser/setUserExpert')}", post_data, function (data) {
                if(data.code != 200){
                    $(".loading").fadeOut();
                    $(".yunBei").css("display","none")
                    shibai_alert(data.msg);
                    return false;
                }
                btn_alert("操作成功", 2000, function () {
                    window.location.href = document.referrer;
                });
            }, 'json')
        });


        $(".cattle span").hide();
        $(".cattle span.good-brand").show();
        var arrV=[];
        $(".cattle").on("click","dd",function(){
            if($(".brand-choice ul li").length==3){
                shibai_alert("选择的擅长品牌不能超过3个");
                $(".yunBei").css("zIndex",99999);
                return false;
            }
            if($(this).html()=="清空"){
                return false
            }
            var thatHtml=$(this).html();
            var thatId=$(this).attr("brand_id");
            arrV.push(thatId);
            $("#good_brand").val(arrV);
            $(".brand-choice ul li").each(function(){
                var thisText=$(this).find("i").html();
                if(thisText.indexOf(thatHtml)!=-1){
                    $(this).remove();
                    var dArrV=arrV.pop();
                    $("#good_brand").val(arrV)
                    shibai_alert("选择的擅长品牌不能相同");
                    $(".yunBei").css("zIndex",99999);
                    return false;
                }
            })
            var oLi="<li>"+"<i>"+$(this).html()+"</i>"+"<span>×</span>"+"</li>"
            $(".brand-choice ul").append(oLi);
        })
        $(".brand-choice").on("click","span",function(){
            $(this).parents("li").remove();
        });
    })
</script>
<include file="Public/foot"/>